package com.ecode.ecny.exception;

import com.ecode.ecny.base.AppContext;
import lombok.Data;

/**
 * @ClassName ConvertException
 * @Author mjlft
 * @Date 2021/8/14 11:36
 * @Version 1.0
 * @Description 自定义异常, 定义为运行是异常，然后统一使用增强处理器进行处理，该异常一般只用在Controller中
 */
@Data
public class TrxException extends RuntimeException{
    private String trxCode;
    private String trxStatus;
    private String trxMsg;
    private String srcSys;
    private String targetSys;

    public TrxException(TrxErrorEnums trxErrorEnums, String trxStatus) {
        this(trxErrorEnums.getCode(), trxStatus, trxErrorEnums.getMsg());
    }

    public TrxException(String trxCode, String trxStatus, String trxMsg) {
        this(trxCode, trxStatus, trxMsg, AppContext.ECNY_SYS, AppContext.ECNY_SYS);
    }

    public TrxException( String trxCode, String trxStatus, String trxMsg, String srcSys, String targetSys) {
        super(trxMsg);
        this.trxCode = trxCode;
        this.trxStatus = trxStatus;
        this.trxMsg = trxMsg;
        this.srcSys = srcSys;
        this.targetSys = targetSys;
    }
}
